package com.ruoyi.project.wms.logistics.jinhuo.store.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.wms.inGoods.domain.WmsInGoods;
import com.ruoyi.project.wms.inGoods.mapper.WmsInGoodsMapper;
import com.ruoyi.project.wms.logistics.jinhuo.store.service.IJinWmsStoreService;
import com.ruoyi.project.wms.store.domain.WmsStore;
import com.ruoyi.project.wms.store.mapper.WmsStoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-07
 */
@Service
public class JinWmsStoreServiceImpl implements IJinWmsStoreService
{
    @Resource
    private WmsStoreMapper wmsStoreMapper;

    @Resource
    private WmsInGoodsMapper wmsInGoodsMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param sid 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public WmsStore selectWmsStoreById(Long sid)
    {
        return wmsStoreMapper.selectWmsStoreById(sid);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param wmsStore 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<WmsStore> selectWmsStoreList(WmsStore wmsStore)
    {
        wmsStore.setSstatus("库存不足");
        return wmsStoreMapper.selectWmsStoreList(wmsStore);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param wmsStore 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertWmsStore(WmsStore wmsStore)
    {
        return wmsStoreMapper.insertWmsStore(wmsStore);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param wmsStore 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateWmsStore(WmsStore wmsStore)
    {
        return wmsStoreMapper.updateWmsStore(wmsStore);
    }

    /**
     * 删除【请填写功能名称】对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWmsStoreByIds(String ids)
    {
        return wmsStoreMapper.deleteWmsStoreByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param sid 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int updateWmsStoreStatusById(Long sid)
    {
        return 1;
    }

    @Override
    public int createjinhuo(WmsStore wmsStore) {
        WmsInGoods wmsInGoods = new WmsInGoods();
        wmsInGoods.setIgnum(wmsStore.getSnum());
        wmsInGoods.setIgpname(wmsStore.getSname());
        wmsInGoods.setIgstatus("未入库");
        wmsInGoods.setIgcreatedate(new Date());
        //更新库存状态正在进货
        WmsStore wmsStore1 = new WmsStore();
        wmsStore1.setSid(wmsStore.getSid());
        wmsStore1.setSstatus("进货中");
        int i = wmsStoreMapper.updateWmsStore(wmsStore1);

        //生成进货单
        int i1 = wmsInGoodsMapper.insertWmsInGoods(wmsInGoods);

        return i1;
    }
}
